package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ApkVersionDao;
import com.sugon.entity.ApkVersionEntity;
import com.sugon.service.ApkVersionService;
import com.sugon.utils.ShiroUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * APK版本Service实现类
 *
 * @author sugon
 * @date 2020-04-21 11:52:46
 */
@Service("apkVersionService")
public class ApkVersionServiceImpl implements ApkVersionService {

    @Resource
    private ApkVersionDao apkVersionDao;

    /**
     * queryObject
     *
     * @param id 主键
     * @return
     */
    @Override
    public ApkVersionEntity queryObject(String id) {
        return apkVersionDao.queryObject(id);
    }

    /**
     * queryList
     *
     * @param map 参数
     * @return
     */
    @Override
    public List<ApkVersionEntity> queryList(Map<String, Object> map) {
        return apkVersionDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map 参数
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return apkVersionDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param apkVersion 实体
     * @return
     */
    @Override
    public int save(ApkVersionEntity apkVersion) {
        apkVersion.setId(RandomUtil.randomString(32));
        apkVersion.setCreateTime(DateUtil.date());
        apkVersion.setCreateUser(ShiroUtils.getUserId());
        return apkVersionDao.save(apkVersion);
    }

    /**
     * update
     *
     * @param apkVersion 实体
     * @return
     */
    @Override
    public int update(ApkVersionEntity apkVersion) {
        return apkVersionDao.update(apkVersion);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {
        return apkVersionDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return apkVersionDao.deleteBatch(ids);
    }

    /**
     * loadByMaxVersion
     *
     * @param clientType 客户端类型
     * @return
     */
    @Override
    public ApkVersionEntity loadByMaxVersion(String clientType) {
        return apkVersionDao.loadByMaxVersion(clientType);
    }

}
